package com.bkitmobile.kesu.android.ClassInfo;

import java.util.List;
import com.bkitmobile.kesu.android.GUI.R;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class LocationsListAdapter extends ArrayAdapter<LocationShortInfo>{
	private Activity context;
	private List<LocationShortInfo> objects;
	
	public LocationsListAdapter(Activity context, List<LocationShortInfo> objects) {
		super(context, R.layout.location__find_location_object, objects);
		this.context = context;
		this.objects = objects;
		
		
	}
	
	public View getView(int position,  View convertView, ViewGroup parent) {
		View row = convertView;
		if(row == null){
			LayoutInflater inflater = context.getLayoutInflater();
			row = inflater.inflate(R.layout.location__find_location_object, null);
		}
		TextView type, name, address;
		type = (TextView) row.findViewById(R.id.findLocationObject_tvType);
		name = (TextView) row.findViewById(R.id.findLocationObject_tvName);
		address = (TextView) row.findViewById(R.id.findLocationObject_tvAddress);
		
		type.setText(objects.get(position).getTypeLoc());
		name.setText(objects.get(position).getNameLoc());
		address.setText(objects.get(position).getAddressLoc());
		return row;
	}

}
